<?php

/**
* FONCTION Requete SQL SELECT
*/
function bddSelect($bdd, $champs, $table, $where_id) {

	$pdo_select = connexionTable($bdd); 

	$sql_select = 'SELECT ' . $champs;
	$sql_select .= ' FROM ' . $table;
	$sql_select .= ' WHERE ' . $where_id;
	
//         var_dump($sql_select);
        
	$request_select = $pdo_select->query($sql_select);
	
	return $request_select;	
}

/**
* FONCTION Requete SQL INSERT
*/
function bddInsert($bdd, $table, $values) {

	$pdo_insert = connexionTable($bdd); 

	$sql_insert = 'INSERT INTO '.$table; 
	$sql_insert .= ' VALUES ' . $values;
		
//        var_dump($sql_insert);
        
	$nb_insert = $pdo_insert->exec($sql_insert);
	
	return $nb_insert;	
}

/**
* FONCTION Requete SQL UPDATE
*/
function bddUpdate($bdd, $table, $set, $where_id) {

	$pdo_update = connexionTable($bdd); 

	$sql_update = 'UPDATE '.$table; 
	$sql_update .= ' SET ' . $set;
	$sql_update .= ' WHERE ' . $where_id;
	
//        var_dump($sql_update);
        
	$nb_update = $pdo_update->exec($sql_update);
	
	return $nb_update;
}

/**
* FONCTION Requete SQL DELETE
*/
function bddDelete($bdd, $table, $where_id) {

	$pdo_delete = connexionTable($bdd); 

	$sql_delete = 'DELETE FROM '.$table; 
	$sql_delete .= ' WHERE ' . $where_id;
	
//        var_dump($sql_delete);
        
	$nb_delete = $pdo_delete->exec($sql_delete);
	
	return $nb_delete;
}

?>